]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
tests: Drop wrapper script for unit test runner
authorFlorian Müllner <fmuellner@gnome.org>
Sat, 20 Jan 2024 06:46:03 +0000 (07:46 +0100)
committerMarge Bot <marge-bot@gnome.org>
Tue, 21 May 2024 13:42:28 +0000 (13:42 +0000)
We build a small run-js-test executable so tests run in a
similar environment as gnome-shell, and then wrap it with
a generated script that provides environment variables like
GI_TYPELIB_PATH.

This is more complicated than it needs to be, we can just as
well set up the typelib search path from the runner and pass
in the environment via meson.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3164>

src/main.c
src/meson.build
src/run-js-test.c
tests/meson.build
tests/run-test.sh.in [deleted file]

index 10b5f6eb0f8a453d81e0283e4a112e9a7ef54928..4be47258ebc554a19c629253045ca93ad4fbe13b 100644 (file)
@@ -222,7 +222,7 @@ shell_introspection_init (void)
 {
 
   g_irepository_prepend_search_path (MUTTER_TYPELIB_DIR);
-  g_irepository_prepend_search_path (GNOME_SHELL_PKGLIBDIR);
+  g_irepository_prepend_search_path (SHELL_TYPELIB_DIR);
 
   /* We need to explicitly add the directories where the private libraries are
    * installed to the GIR's library path, so that they can be found at runtime
index 422a68d8dd63e9562fd15f9308b4635f0474bb55..456e5e70c29bc1e110d282ce3a1a2dbe765ba6b6 100644 (file)
@@ -45,6 +45,11 @@ install_data('gnome-shell-extension-prefs',
   install_dir: bindir
 )
 
+typelib_cflags = [
+  '-DMUTTER_TYPELIB_DIR="@0@"'.format(mutter_typelibdir),
+  '-DSHELL_TYPELIB_DIR="@0@"'.format(pkglibdir),
+]
+
 gnome_shell_cflags = [
   '-DCLUTTER_ENABLE_EXPERIMENTAL_API',
   '-DCOGL_ENABLE_EXPERIMENTAL_API',
@@ -248,9 +253,7 @@ libshell_gir = gnome.generate_gir(libshell,
 )
 
 executable('gnome-shell', 'main.c',
-  c_args: gnome_shell_cflags + [
-    '-DMUTTER_TYPELIB_DIR="@0@"'.format(mutter_typelibdir)
-  ],
+  c_args: gnome_shell_cflags + typelib_cflags,
   dependencies: gnome_shell_deps + [libshell_dep, libst_dep, mutter_dep],
   include_directories: [conf_inc, st_inc, include_directories('tray')],
   build_rpath: mutter_typelibdir,
@@ -276,8 +279,9 @@ executable('gnome-shell-perf-helper', 'shell-perf-helper.c', js_resources,
   install: true
 )
 
-executable('run-js-test', 'run-js-test.c',
+run_test = executable('run-js-test', 'run-js-test.c',
   dependencies: [mutter_dep, mtk_dep, gdk_pixbuf_dep, gio_dep, gi_dep, gjs_dep],
+  c_args: typelib_cflags,
   include_directories: [conf_inc],
   link_with: libshell,
   build_rpath: mutter_typelibdir,
index 7ebaa0bbd0d08f9ec2763270d4245d0f0979c75d..87babad6691a56d2cf21630c4a2501e123296149 100644 (file)
@@ -61,6 +61,9 @@ main(int argc, char **argv)
   global = shell_global_get ();
   js_context = _shell_global_get_gjs_context (global);
 
+  g_irepository_prepend_search_path (MUTTER_TYPELIB_DIR);
+  g_irepository_prepend_search_path (SHELL_TYPELIB_DIR);
+
   /* prepare command line arguments */
   if (!gjs_context_define_string_array (js_context, "ARGV",
                                         argc - 2, (const char**)argv + 2,
index da4d40f0503b78bc0c5cee7930f53fab2dd72f12..286ad7ab3436f5b8517eedded1cf110fd6b25156 100644 (file)
@@ -1,12 +1,3 @@
-testconf = configuration_data()
-testconf.set('MUTTER_TYPELIB_DIR', mutter_typelibdir)
-testconf.set('srcdir', meson.current_source_dir())
-run_test = configure_file(
-  input: 'run-test.sh.in',
-  output: 'run-test.sh',
-  configuration: testconf
-)
-
 mutter_tests_datadir = mutter_test_dep.get_variable('tests_datadir')
 dbusrunnerconf = configuration_data()
 dbusrunnerconf.set('MUTTER_TEST_PKGDATADIR', mutter_tests_datadir)
@@ -18,6 +9,16 @@ dbus_runner = configure_file(
   configuration: dbusrunnerconf,
 )
 
+gvc_typelib_path = fs.parent(libgvc.get_variable('libgvc_gir')[1].full_path())
+shell_typelib_path = fs.parent(libshell_gir[1].full_path())
+st_typelib_path = fs.parent(libst_gir[1].full_path())
+
+unit_testenv = environment()
+unit_testenv.set('GNOME_SHELL_DATADIR', data_builddir)
+unit_testenv.append('GI_TYPELIB_PATH', gvc_typelib_path, separator: ':')
+unit_testenv.append('GI_TYPELIB_PATH', shell_typelib_path, separator: ':')
+unit_testenv.append('GI_TYPELIB_PATH', st_typelib_path, separator: ':')
+
 unit_tests = [
     'highlighter',
     'injectionManager',
@@ -34,6 +35,7 @@ foreach test : unit_tests
   test(test, run_test,
     args: 'unit/@0@.js'.format(test),
     suite: 'unit',
+    env: unit_testenv,
     workdir: meson.current_source_dir())
 endforeach
 
@@ -53,7 +55,6 @@ shell_tests = [
   },
 ]
 
-gvc_typelib_path = fs.parent(libgvc.get_variable('libgvc_gir')[1].full_path())
 libgvc_path = fs.parent(libgvc.get_variable('libgvc').full_path())
 
 background_file = join_paths(meson.current_source_dir(), 'data', 'background.png')
diff --git a/tests/run-test.sh.in b/tests/run-test.sh.in
deleted file mode 100755 (executable)
index ea6d157..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/sh
-
-usage() {
-    echo >&2 "Usage run-test.sh [-v|--verbose] <test_js>..."
-    exit 1
-}
-
-tests=
-verbose=false
-debug=
-for arg in $@ ; do
-    case $arg in
-       -g|--debug)
-           debug="libtool --mode=execute gdb --args"
-           ;;
-       -v|--verbose)
-           verbose=true
-           ;;
-       -*)
-           usage
-           ;;
-       *)
-           tests="$tests $arg"
-           ;;
-    esac
-done
-
-builddir=`dirname $0`
-builddir=`cd $builddir && pwd`
-srcdir=@srcdir@
-srcdir=`cd $srcdir && pwd`
-
-GI_TYPELIB_PATH="$GI_TYPELIB_PATH${GI_TYPELIB_PATH:+:}@MUTTER_TYPELIB_DIR@:$builddir/../src:$builddir/../src/st:$builddir/../subprojects/gvc"
-GJS_PATH="$srcdir:$srcdir/../js:$builddir/../js"
-GJS_DEBUG_OUTPUT=stderr
-$verbose || GJS_DEBUG_TOPICS="JS ERROR;JS LOG"
-GNOME_SHELL_TESTSDIR="$srcdir/"
-GNOME_SHELL_JS="$srcdir/../js"
-GNOME_SHELL_DATADIR="$builddir/../data"
-
-export GI_TYPELIB_PATH GJS_PATH GJS_DEBUG_OUTPUT GJS_DEBUG_TOPICS GNOME_SHELL_TESTSDIR GNOME_SHELL_JS GNOME_SHELL_DATADIR LD_PRELOAD
-
-for test in $tests ; do
-    $debug $builddir/../src/run-js-test $test || exit $?
-done